package com.yzg.lock;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author misterWei
 * @create 2020年05月13号:14点03分
 * @mailbox forcontinue@163.com
 *
 * 可重入锁的使用范例
 */
@Slf4j(topic = "c.lock")
public class Locks {
    private static final ReentrantLock lock = new ReentrantLock();
    public static void main(String[] args) {
        lock.lock();
        try {
            //临界区
            System.out.println(System.getProperty("os.name"));
        }finally {
            lock.unlock();
        }
    }
}
